package com.after.saas.file.converter;

import com.after.saas.common.model.bo.UserBO;
import com.after.saas.common.model.vo.UserVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;


/**
 * @Classname UserConverter
 * @Description TODO
 * @auth after
 * @since 2023/6/11 12:14
 */
@Mapper
public interface UserConverter {

    UserConverter INSTANCE = Mappers.getMapper(UserConverter.class);

    @Mapping(target = "token", source = "jwt")
    @Mapping(target = "createTime", defaultExpression = "java(java.time.LocalDateTime.now())")
    @Mapping(target = "updateTime", expression = "java(cn.hutool.core.date.DateUtil.parseLocalDateTime(userBO.getUpdateTime(),\"yyyy-MM-dd HH:mm:ss\"))")
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "password", defaultValue = "123456")
    UserVO toUserVO(UserBO userBO);
}
